package com.nulldev.util.web.nCaptcha.backend;

import com.nulldev.util.uri.server.HttpPage;
import com.nulldev.util.uri.server.RequestType;
import com.nulldev.util.web.nCaptcha.backend.user.User;
import com.nulldev.util.web.nCaptcha.backend.user.UserManager;

public class RemoveCaptchaState extends HttpPage {

	public RemoveCaptchaState() {
		super("/dev/remove_captcha");
	}
	
	@Override
	public String handleRequest(String args, String ip, RequestType type) {
		final User user = UserManager.registerOrLoadUser(ip);
		if (user.isNotBot()) {
			if (UserManager.removeUser(user)) {
				return "/dev/remove_captcha: Removed.";
			}else {
				return "/dev/remove_captcha: Failed to remove user.";
			}
		}
		return "/dev/remove_captcha: Request rejected.";
	}
	
	/**
	 * Unused
	 */
	@Override
	public byte[] handleRequest_Alt(String args, String ip, RequestType type) {
		return null;
	}

}
